package com.ntv.persistent.video;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;

import com.ntv.domain.IVideo;
import com.ntv.persistent.AbstractDao;
import com.ntv.persistent.PersistentException;

/**
 * @author Vedamoorthi Vairam
 * @since 05/01/2009
 *
 */
public class SqlVideoDao extends AbstractDao implements IVideoDao {

	interface QUERY {
		final String FIND_VIDEO_BY_ID = "";	

		final String FIND_VIDEO_BY_NAME= "";
	}
	
	
	public List<IVideo> getVideos() throws PersistentException 
	{
		return null;
	}

	public IVideo findVideoByID(Long videoId) throws PersistentException 
	{
		SqlParameterSource namedParameters = new MapSqlParameterSource("ID", videoId);
		try 
		{
			return (IVideo) getNamedParameterJdbcTemplate().queryForObject(
					QUERY.FIND_VIDEO_BY_ID, namedParameters, getRowMapper());
		}
		catch (DataAccessException e) 
		{
			throw new PersistentException(e);
		}
	}

	public IVideo findVideoByName(String name) throws PersistentException 
	{
		SqlParameterSource namedParameters = new MapSqlParameterSource("NAME", name);
		try 
		{
			return (IVideo)getNamedParameterJdbcTemplate().queryForObject(QUERY.FIND_VIDEO_BY_NAME, namedParameters, getRowMapper());
		}
		catch (DataAccessException e) 
		{
			throw new PersistentException(e);
		}
	}

}
